
</htm>

<head>
    <meta charset="UTF-8">
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <include file="public@head" title="短信设置" keywords="后台管理系统"/>
    <link href="__STATIC__/umeditor/themes/default/css/umeditor.css" type="text/css" rel="stylesheet">
</head>

<body class="layui-layout-admin">
<include file="public@header"/>
<include file="public@side"/>
<div class="layui-body">

    <div class="layui-breadcrumb" lay-filter="breadcrumb">
        <a href="{:url('tdadmin/index/index')}">主页</a>
        <a>系统设置</a>
        <a href="{:url('tdadmin/sms/index')}"><cite>短信设置</cite></a>
    </div>
    <div class="layui-tab">
        <ul class="layui-tab-title">
            <li class="layui-this"><a href="{:url('tdadmin/sms/index')}">短信设置</a></li>
            <li><a href="{:url('tdadmin/sms/template')}">短信模板</a></li>
        </ul>
    </div>

    <div class="layui-fluid">
        <div class="layui-row">
            <div class="layui-card">

            <foreach name="templates" item="vo">

                <form method="post" class="layui-form layui-col-md6 padding-top-10" role="form"
                      action="{:url('tdadmin/sms/template')}">
                    <div class="layui-form-item">
                        <label class="layui-form-label"><span class="form-required">*</span>短信类别</label>
                        <div class="layui-input-block">
                            <input type="text" class="layui-input" lay-verify="required" name="subject"
                                   value="{$vo.subject|default=''}">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">短信模板</label>
                        <div class="layui-input-block">
                            <input type="text" class="layui-input" lay-verify="required" value="{$vo.content}"
                                   name="content">
                            <literal><span style="color: #ffb752;">请用{$code}代替数字验证码，{$username}代替用户名</span></literal>
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">模板编号</label>
                        <div class="layui-input-block">
                            <input type="text" class="layui-input" lay-verify="required" value="{$vo.templateCode|default=''}"
                                   name="templateCode">
                            <literal><span style="color: #ffb752;">与阿里短信中配置保持一致</span></literal>
                        </div>
                    </div>

                    <div class="layui-form-item">
                        <div class="layui-input-block">
                            <input type="hidden" name="template_key" value="{$vo.option_name}">
                            <button type="submit" class="layui-btn layui-btn-primary" lay-submit lay-filter="save">保存
                            </button>
                        </div>
                    </div>
                </form>
            </foreach>

            </div>
            <div>
                <p>新建模板</p>
                <form method="post" class="layui-form layui-col-md6 padding-top-10" role="form"
                      action="{:url('tdadmin/sms/add')}">
                <div class="layui-form-item">
                    <label class="layui-form-label"><span class="form-required">*</span>模板key值</label>

                    <div class="layui-input-block">
                <input type="text" class="layui-input" lay-verify="required" type="text" name="template_key" value="" placeholder="请输入模板key值">
                </div>
                </div>
                    <div class="layui-form-item">
                        <div class="layui-input-block">
                            <button  class="layui-btn layui-btn-primary" lay-submit lay-filter="add">添加新模板</button>
                        </div>
                    </div>
                </form>
            </div>

        </div>
    </div>
    <include file="public@scripts"/>
    <script src="__STATIC__/layui/layui.all.js"></script>
    <script>
        var element = layui.element,
            form = layui.form,
            $ = layui.jquery,
            jQuery = layui.jquery,
            layer = layui.layer;
    </script>
    <script type="text/javascript" src="__STATIC__/ueditor/ueditor.config.js"></script>
    <script type="text/javascript" src="__STATIC__/ueditor/ueditor.all.js"></script>
    <script>
        form.on('submit(save)', function (data) {
            $.post("{:url('tdadmin/sms/template')}", data.field, function (res) {
                if (res.code == 1) {
                    layer.msg(res.msg, {
                        icon: 6
                    }, function () {
                        window.location.href = res.url;
                    });
                } else {
                    layer.msg(res.msg, {
                        icon: 5
                    }, function () {
                        return false;
                    });
                }
            });
            return false;
        });

        form.on('submit(add)', function (data) {
            $.post("{:url('tdadmin/sms/add')}", data.field, function (res) {
                if (res.code == 1) {
                    layer.msg(res.msg, {
                        icon: 6
                    }, function () {
                        window.location.href = res.url;
                    });
                } else {
                    layer.msg(res.msg, {
                        icon: 5
                    }, function () {
                        return false;
                    });
                }
            });
            return false;
        });
    </script>
</div>
</body>

</html>